package oj.util.server;

import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.SQLException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class OjBeanConexion implements SessionBean {

	/** pool de Conexciones a Bases de Datos.. */
	public static Connection getConnection() throws NamingException,
			SQLException {
		Connection cnn = null;
		try {
			InitialContext inicial = new InitialContext();

			DataSource ds = (DataSource) inicial.lookup("java:DSSapiens");
			try {
				cnn = ds.getConnection();

			} catch (Exception ex) {
				ex.printStackTrace();
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

		return cnn;
	}

	public void ejbCreate() {
	}

	public void ejbActivate() throws EJBException, RemoteException {
	}

	public void ejbPassivate() throws EJBException, RemoteException {
	}

	public void ejbRemove() throws EJBException, RemoteException {
	}

	public void setSessionContext(SessionContext arg0) throws EJBException,
			RemoteException {
	}

}
